package com.parsechina.hpush.broker.internal;

import java.io.Serializable;
import java.util.Objects;

/**
 * Value object for GUIDs of messages.
 * @author linfeng
 */
public class MessageGUID implements Serializable {

    private static final long serialVersionUID = -5643906675838757258L;
    private final String guid;
    private boolean storage = false;

    public MessageGUID(String guid) {
        this.guid = guid;
    }

    public String getGuid() {
        return guid;
    }

    public boolean isStorage() {
        return storage;
    }

    public void setStorage(boolean storage) {
        this.storage = storage;
    }

    @Override
    public String toString() {
        return guid;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        MessageGUID that = (MessageGUID) o;
        return storage == that.storage &&
                Objects.equals(guid, that.guid);
    }

    @Override
    public int hashCode() {
        return Objects.hash(guid, storage);
    }
}
